<template>
  <template v-for="(item, index) in stu" :key="item">
    <div>
      <span>姓名-{{ item.name }}</span>
      <span>年龄-{{ item.age }}</span>
      <button @click="addClick(item)">+ 1</button>
      <button @click="deleClick(index)">删除</button>
    </div>
  </template>
</template>

<script>
export default {
  name: 'HelloWorld',
  data() {
    return {
      stu: [
        {
          name: 'zjd',
          age: 19,
        },
        {
          name: 'qq',
          age: 18,
        },
      ],
    }
  },
  methods: {
    addClick(item) {
      item.age += 1
    },
    deleClick(index) {
      this.stu.splice(index, 1)
    },
  },
}
</script>
<style scoped></style>
